package smartcarpool.ui;

import com.example.smartcarpool.R;

import android.app.Activity;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.EditText;
import android.widget.Spinner;

public class SCSpinnerListener extends Activity implements
		OnItemSelectedListener {

	private Spinner spnLocale;
	private View view;

	public SCSpinnerListener(Spinner spn, View formView) {
		this.spnLocale = spn;
		this.view = formView;
		Log.d("Spinner Listener construct", "new listener"+spnLocale.toString());
	}

	@Override
	public void onItemSelected(AdapterView<?> arg0, View arg1, int item,
			long arg3) {

		Log.d("Item selected", String.valueOf(item));
		if (spnLocale == view.findViewById(R.id.spinner1)) {
			if (item == 0) {
				this.view.findViewById(R.id.vehicle_frame).setVisibility(
						View.VISIBLE);
				// this.view.findViewById(R.id.vehicle_frame).
			} else {
				this.view.findViewById(R.id.vehicle_frame).setVisibility(
						View.GONE);
			}
		} else {
			EditText et1 = (EditText) this.view.findViewById(R.id.editText1);
			EditText et2 = (EditText) this.view.findViewById(R.id.editText2);
			switch (item) {
			case 0:
				et1.setText("4");
				et2.setText("4");
				break;

			case 1:
				et1.setText("5");
				et2.setText("6");
				break;

			case 2:
				et1.setText("12");
				et2.setText("12");
				break;
			default:
				break;
			}
		}

	}

	@Override
	public void onNothingSelected(AdapterView<?> arg0) {
		// TODO Auto-generated method stub
		return;
	}

}
